package com.example.schoolexam2.mapper;

import com.example.schoolexam2.entity.DepartmentTableBean;
import com.example.schoolexam2.entity.Employee;
import com.example.schoolexam2.entity.PageVO;
import com.example.schoolexam2.entity.PowerVO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface PowerMapper {
    //获取指定用户的权限类型
    @Select("select distinct mname from view_power where uid=#{uid}")
    List<String> getPowerType(PowerVO power);
    //获取指定用户的所有权限
    @Select("select * from view_power where uid=#{uid}")
    List<PowerVO> getPower(PowerVO power);
    //查询所有部门
    @Select("select * from department_table")
    List<DepartmentTableBean> getDepartment();

    @Select("select departmentId from department_table where departmentName=#{departmentName}")
    String findIdByName(String departmentName);

    //查询所有教师
    @Select("select * from employee")
    List<Employee> getTearcher();
    //获取所有权限名称
    @Select("select * from tb_pages")
    List<PageVO> getPages();
    //新增用户权限
    @Insert("insert into tb_power (uid,utype,pageid) select #{uid},#{utype},#{pageid} from dual where not exists (select * from tb_power where 1=1 and uid=#{uid} and pageid=#{pageid}) ")
    int addPower(String uid, String utype, int pageid);
}
